文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. 编译C++程序
要编译的C++程序如下,文件名为spiral_matrix.cpp。
1 |
|
使用g++进行编译,编译命令为g++ -g spiral_matrix.cpp -o test,-g参数表示编译时加入调试信息。
2. GDB调试
执行命令gdb test进入调试:
1 | GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7 |
输入命令list 10查看代码,list <line_number>表示查看某行代码附近的代码。list 10也可简写为l 10。
1 | (gdb) list 10 |